<template>
	<view class="conter">

		<view class="header" @tap="goBack(id)">
			<view class="arrow">
			</view>
			<view class="title">
				{{title}}
			</view>
		</view>

		<view class="flex-box" style="padding: 20rpx 0 0 30rpx;
				background-color:#4F5394;">
			<view class="left-box" style="display: flex;
					align-items: center;color: #FFFFFF;">
				<view class="left-image">
					<open-data class="user-avatar" type="userAvatarUrl"></open-data>
				</view>
				<view class="">
					<open-data class="user-name" type="userNickName"></open-data>
				</view>
			</view>
			<view @tap="jump('/pages/site/uploadPhone')" class="money ">
				<view class="money-image">
					<image src="../../static/index/fb.png" mode=""></image>
				</view>
				上传图册
			</view>
		</view>





		<view class="" style="padding: 0 30rpx;
			background-color:#4F5394; color: #FFFFFF; line-height: 50rpx;">
			<view class="flex align-center justify-around h200">
				<view class="text-center" @tap="jump('/pages/site/money')">
					<view class="f36">
						{{ money ? money : 0.00}}
					</view>
					<view class="">
						我的收益
					</view>
				</view>
				<view class="text-center" @tap="jump('/pages/site/chusholist')">
					<view class="f36">
						{{sc ? sc : 0}}
					</view>
					<view class="">
						上传图册
					</view>
				</view>
				<!-- <view class="text-center" @tap="jump('/pages/site/orderList')">
					<view class="f36">
						{{list.length ? list.length : 0}}
					</view>
					<view class="">
						我的订单
					</view>
				</view> -->
				<view class="text-center" @tap="jump('/pages/site/photoList')">
					<view class="f36">
						{{ sh ? sh : 0}}
					</view>
					<view class="">
						图册审核
					</view>
				</view>
			</view>


		</view>

		<!-- /pages/site/meBuy -->
		<view @tap="jump('/pages/site/listInfo')" class="me-shopping">
			<view class="">
				我购买的
			</view>
			<view class="flex align-center">
				 <view class="">
					{{mayBuy.length}} 套
				</view>
				<text class="cuIcon-right"></text>
			</view>
		</view>


		<!-- 	<view class="cu-avatar-group">
			<view class="cu-avatar round lg bgc" v-for="(item,index) in userList" :key="index"
				:style="[{ backgroundImage:'url(' + item.avatar + ')'}]">
			</view>
		</view> -->



		<view class="" style="width: 100%; height: 20rpx; background-color: #F8F8F8;">

		</view>


		<view class="" style="padding: 0 30rpx;">


			<view @tap="jump('/pages/site/chusholist')" class="flex-box box2">
				<view class="" style="color: #000000; font-weight: 600;">
					正在出售
				</view>
				<view class="" style="color: #717171; font-size: 26rpx;">
					共 {{listFrom.length}} 件<text class="cuIcon-right" style="margin-left: 6rpx;"></text>
				</view>
			</view>


			<block v-for="(item, index) in listFrom" :key="index">
				<view class="user-info">
					<view class="flex-box" @tap="navGetto(item.id)">
						<view class="user-info-left">
							<view class="user-image">
								<image :src="imgs + item.image" mode=""></image>
							</view>
							<view class="">
								<view class="text-cut f28"
									style="width: 300rpx; white-space: nowrap;margin-bottom: 10rpx;">
									{{item.title}}
								</view>
								<view class="text-cut f26"
									style="color: #717171; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;width: 300rpx;">
									<u-icon name="map" color="#717171"></u-icon>
									{{item.address}}
								</view>
							</view>
						</view>
						<view class="sold-out">
							已售<text style="margin-left: 6rpx; font-size: 24rpx;">{{item.count}}</text>
						</view>
					</view>
				</view>
			</block>


		</view>






	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				title: '我的',
				count: 4,
				value: 2,
				list: [{
					name: '1111',
					value: 2
				}, {
					name: '3333',
					value: 2
				}],
				img: [],
				money: '',
				sc: '',
				sh: '',
				imgs: this.$images,
				mayBuy: [],
				arrList: [],
				listFrom: [],
			}
		},

		onLoad() {
			this.userInfo()
		},
		onShow() {
			uni.removeStorageSync('led')
			uni.removeStorageSync('xulie')
			uni.removeStorageSync('huoti')
			uni.removeStorageSync('jiedian')
			uni.removeStorageSync('dating')
			uni.removeStorageSync('wutai')
		},
		onReachBottom() {

		},
		methods: {

			jump(url) {
				console.log('url: ', url);
				uni.navigateTo({
					url
				});
			},

			navGetto(init) {
				uni.navigateTo({
					url: '/pages/site/phoneInfo?id=' + init
				})
			},

			async userInfo() {
				const res = await this.$u.post('api/hotel/me?uid=' + uni.getStorageSync('uid'))
				this.money = res.data.money
				this.sc = res.data.sc
				this.sh = res.data.sh
				this.mayBuy = res.data.buy
				this.listFrom = res.data.sell
				// res.data.buy.forEach((i => {
				// 	this.arrList.push(i.picture)
				// }))
				console.log('请求成功userInfo', res )
			},


			goBack(id) {
				console.log(id)
				uni.navigateBack({
					delta: 1
				})
			},



			image() {
				console.log(9999);
				uni.previewImage({
					urls: [...this.img],
					longPressActions: {
						itemList: ['发送给朋友', '保存图片', '收藏'],
						success: function(data) {
							console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
						},
						fail: function(err) {
							console.log(err.errMsg);
						},
					},
				});
			},

			buy() {
				console.log('唤起支付')
				uni.requestPayment({
					provider: 'wxpay',
					timeStamp: String(Date.now()),
					nonceStr: 'A1B2C3D4E5',
					package: 'prepay_id=wx20180101abcdefg',
					signType: 'MD5',
					paySign: '',
					success: function(res) {
						console.log('success:' + JSON.stringify(res));
					},
					fail: function(err) {
						console.log('fail:' + JSON.stringify(err));
					}
				});

			},

			// 复制文本
			copy() {
				uni.setClipboardData({
					data: 'hello',
					success: function() {
						console.log('success');
						// this.$tools.msg('复制成功')
					}
				});

				// uni.getClipboardData({
				//     success: function (res) {
				//         console.log(res.data);
				//     }
				// });
			}
		}
	}
</script>

<style lang="scss" scoped>
	.conter {
		width: 100%;
		height: 100vh;
		// padding: 0 30rpx;
		background-color: #FFFFFF;

		image {
			width: 100%;
			height: 100%;
		}



		.header {
			width: 100%;
			height: 150rpx;
			line-height: 150rpx;
			display: flex;
			align-items: center;
			color: #FFFFFF;
			padding-top: 30rpx;
			font-size: 36rpx;
			font-family: PingFang SC;
			font-weight: 500;
			background: #4F5394;

			.arrow {
				position: relative;
				display: inline-block;
			}

			.arrow::before {
				content: '';
				width: 10px;
				height: 10px;
				border: 0px;
				border-bottom: solid 2px #ffffff;
				border-left: solid 2px #ffffff;
				-ms-transform: rotate(45deg);
				-webkit-transform: rotate(45deg);
				transform: rotate(45deg);
				position: absolute;
				top: 50%;
				left: 0;
				margin-top: -4px;
				margin-left: 28rpx;
			}

			.title {
				margin: 0 auto;
			}
		}





		.left-box {

			.left-image {
				width: 120rpx;
				height: 120rpx;
				margin-right: 20rpx;
				overflow: hidden;
				border-radius: 60rpx !important;

				image {
					width: 100%;
					height: 100%;
					border-radius: 60rpx !important;
				}
			}
		}

		.money {
			width: 228rpx;
			height: 56rpx;
			display: flex;
			padding: 0 33rpx;
			align-items: center;
			border-radius: 25rpx 0 0 25rpx;
			color: #54599B;
			font-size: 28rpx;
			background: RGBA(238, 238, 245, 1);

			.money-image {
				width: 30rpx;
				height: 30rpx;
				margin-right: 19rpx;
			}
		}



		.box-info {
			width: 100%;
			height: 138rpx;
			padding-top: 35rpx;
			padding: 0 30rpx;
			color: #FFFFFF;
			background-color: #4F5394;
			border-radius: 16rpx;

			.balance {
				width: 198rpx;
				height: 58rpx;
				border-radius: 29rpx;
				line-height: 58rpx;
				text-align: center;
				color: #4F5394;
				font-size: 30rpx;
				background-color: #FFFFFF;
			}
		}



		.me-shopping {
			width: 100%;
			height: 118rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 0 20rpx;
		}



		.box2 {
			width: 100%;
			height: 90rpx;
			color: #717171;
			line-height: 90rpx;
		}


		.user-info {
			width: 100%;
			// height: 140rpx;
			// line-height: 100rpx;
			margin: 10rpx auto;
			color: #232323;
			display: flex;
			align-items: center;
			border-radius: 10rpx;
			border-bottom: 1rpx solid #F8F8F8;

			.user-info-left {
				display: flex;
				align-items: center;
			}

			.user-image {
				width: 200rpx;
				height: 200rpx;
				border-radius: 10rpx;
				margin-right: 30rpx;

				image {
					border-radius: 10rpx;
				}
			}

			.sold-out {
				width: 160rpx;
				height: 50rpx;
				line-height: 50rpx;
				text-align: center;
				border-radius: 25rpx;
				color: #ECA700;
				background: rgba(236, 167, 0, .1);
			}
		}

		.user-info:last-child {
			border-bottom: 0;
		}

	}
</style>
